<template>
	<view class="">
		<u-navbar leftText="返回" title="案件详情">
			<view class="u-nav-slot" slot="left" @click="goBack">
				<view class="navbar-left">
					<u-icon name="arrow-left" size="16"></u-icon>
					<span>返回</span>
				</view>
			</view>
		</u-navbar>
		<u-alert class="pdfArea_alert" fontSize="16" type="warning" description="请使用赣政通电脑端上传被申请人答复书及证据材料"></u-alert>
		<view class="pdfArea">
			<iframe class="pdfArea_view" :src="attchDetail.fileUrl" frameborder="0"></iframe>
		</view>
	</view>
</template>

<script>
	import {
		Tp_procmaterialValue
	} from "@/common/enumeration/Tp_procmaterial.js"
	import {
		getTodo,
		getAttachByApplyid
	} from "@/common/api/respond/respond.js"
	export default {
		data() {
			return {
				todoDetail: {}, // 待办详情
				attchDetail: {}, // 材料详情
			}
		},
		async onLoad(options) {
			await this.getTodoDetail(options.id)
		},
		methods: {
			// 返回
			goBack() {
				uni.navigateBack()
			},
			// 获取待办详情
			async getTodoDetail(id) {
				let res = await getTodo({
					id: id
				})
				if (res.code == 0) {
					this.todoDetail = res.data
					this.getAttachDetail(res.data.applyid, Tp_procmaterialValue.ADMRE_REPLY)
				}
			},
			// 获取材料详情
			async getAttachDetail(applyid, mattype) {
				let res = await getAttachByApplyid({
					applyid: applyid,
					mattype: mattype
				})
				if (res.code == 0) {
					if(res.data && res.data.fileUrl) {
						res.data.fileUrl = kkfilePreview(res.data.fileUrl)
					}
					this.attchDetail = res.data
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pdfArea {
		height: calc(100vh - 52rpx);
		width: 100%;
		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		justify-content: flex-start;
		overflow: auto;

		&_view {
			width: 100%;
			height: 100%;
		}
	}
</style>